package com.appstore.action.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/**
 * Check login if user access admin page.
 * 
 * @author zhbhun
 * 
 */
public class AdminLoginCheckInteceptor extends AbstractInterceptor {

	@Override
	public String intercept(ActionInvocation actionInvocation) throws Exception {
		Integer adminId = (Integer) actionInvocation.getInvocationContext()
		        .getSession().get("adminId");
		if (adminId == null) {
			return "relogin";
		} else {
			return actionInvocation.invoke();
		}
	}

}
